FROM centos:centos7.9.2009

MAINTAINER tanghaiyang docker@example.com

ARG SERVICE_NAME

# set environment
# from command "locale -a"
ENV LANG=en_US.utf8
ENV SERVICE_NAME="${SERVICE_NAME}"
ENV BASE_DIR="/opt/${SERVICE_NAME}" \
    JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk"
ENV JAVA="/usr/lib/jvm/java-1.8.0-openjdk/bin/java" \
    CLASSPATH=".:${BASE_DIR}/conf:$CLASSPATH" \
    JVM_XMS="1g" \
    JVM_XMX="1g" \
    JVM_XMN="512m" \
    JVM_MS="128m" \
    JVM_MMS="320m"

WORKDIR ${BASE_DIR}

RUN set -x \
    && yum update -y \
    && yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel wget less iputils nc vim libcurl \
    && yum clean all

RUN mkdir -p target
RUN mkdir -p bin
RUN mkdir -p conf
RUN mkdir -p logs
RUN mkdir -p work

ADD ./target/${SERVICE_NAME}.jar target

COPY bin bin
RUN chmod +x bin/*.sh

COPY src/main/resources conf

EXPOSE [8080, 9555]

VOLUME ["${BASE_DIR}/logs", "${BASE_DIR}/work"]

ENTRYPOINT ["bin/docker-startup.sh"]
